package com.igeek.config.way2;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

/**
 * TODO
 *
 * @author chh
 * @since 2024/5/20
 *
 *利用@ComponentScan将实例对象注入到IOC容器中
 **/
@ComponentScan(basePackages = "com.igeek.config.way2")
public class MyConfig implements FactoryBean<Person> {

    //从IOC容器中获取的bean实例对象其实为Person
    @Override
    //返回实例对象
    public Person getObject() throws Exception {
        return new Person();
    }

    @Override
    //返会实例对象的类
    public Class<?> getObjectType() {
        return Person.class;
    }

    @Override
    //判断是否为单例
    public boolean isSingleton() {
        return true;
    }
}
